namespace ConsoleApp1;

public class Await
{
    public static async Task t1()
    {
        Task<int> downloading = DownloadDocsMainPageAsync();
        Console.WriteLine($"{nameof(t1)}: Launched downloading.");

        int bytesLoaded = await downloading;
        Console.WriteLine($"{nameof(t1)}:Downloaded {bytesLoaded} bytes");
    }

    private static async Task<int> DownloadDocsMainPageAsync()
    {
        Console.WriteLine($"{nameof(DownloadDocsMainPageAsync)}: About to start downloading");
        var client = new HttpClient();
        byte[] content = await client.GetByteArrayAsync("https://img1.baidu.com/it/u=2113428616,299759932&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422");
        Console.WriteLine($"{nameof(DownloadDocsMainPageAsync)}: Finished downloading.");
        return content.Length;
    }
}